<template>
	<div>
		<div style="background:url(http://lak110.gitee.io/gdapp/src/images/banner2.png);background-size:cover;">
			<div class="status-top"></div>
		</div>
		<div style="padding:1rem 0.4rem;">
			<div class="mint-cell" style="display: flex;align-items: center;padding: 0 10px;">
				<span style="width: 105px;font-size: 16px;">派单时间</span>
				<input type="date" style="height: 1.4rem;width: 5rem;">
			</div>
			<div class="mint-cell" style="display: flex;align-items: center;padding: 0 10px;">
				<span style="width: 105px;font-size: 16px;">请选择联系人</span>
				<select v-model="info.receiver" name="" id="" style="height: 1.4rem;width: 5rem;">
					<option :value="item.value" v-for="item in personArr">{{item.text}}</option>
				</select>
			</div>
			<mt-field label="基站情况" disabled placeholder="请输入基站地址" v-model="description"></mt-field>
			<mt-field label="基站编号" disabled placeholder="请输入基站编号" v-model="projectNo"></mt-field>
			<!-- <mt-field v-model="info.reason" label="问题描述" placeholder="请输入问题描述"></mt-field> -->
      <div class="mint-cell" style="display: flex;align-items: center;padding: 0 10px;">
      	<span style="width: 105px;font-size: 16px;">问题描述</span>
        <textarea style="height: 3.82rem;"  v-model="info.reason"  placeholder="请输入问题描述"></textarea>

      </div>
		</div>

		<div style="text-align: center;" @click="setMeterPerson()">
			<mt-button type="primary">确定派单</mt-button>
		</div>
	</div>
</template>

<script>
	import {
		Field,
		Button
	} from 'mint-ui';
	export default {
		components: {
			Field,
			Button
		},
		data() {
			return {
				personArr: [],
				description:'',
				projectNo:'',
				info: {
					meterNo: '',
					reason: '',
					receiver: ''
				}
			}
		},
		methods: {
			findPersonByMeterNo() { //获取电表委派人员
				this.$axios.post('gdiot/meter/findPersonByMeterNo', {
					"meterNo": this.info.meterNo
				}).then((p) => {
					this.personArr = p.data.result;
					if(p.data.result.length>0){
						this.info.receiver = p.data.result[0].value;
					}

				})
			},
			//设置电表委派人
			setMeterPerson() {
				this.$axios.post('gdiot/meter/setMeterPerson', {
					"meterNo": this.info.meterNo,
					"userCode":this.info.receiver
				}).then((p) => {
					this.selectMeterMaintain()
				})
			},
			//确定派单
			selectMeterMaintain() {
				this.$axios.post('gdiot/meter/insertMeterMaintain',this.info).then((p) => {
					if (p.data.error == '100') {
						this.$mint.Toast({
							message: p.data.msg,
							iconClass: 'iconfont icon-dui',
							duration: 1500
						});
						 eventBus.$emit('choiceHospital','eventBus');
						setTimeout(()=>{
							this.$router.back(-1);
						},1500)

					}
				})
			}

		},
		created() {
			this.info.meterNo = this.$route.query.meterNo;
			this.description = this.$route.query.description;
			this.projectNo = this.$route.query.projectNo;
			this.findPersonByMeterNo()
		},
		mounted() {

		}
	}
</script>

<style lang="scss" scoped>
	.status-top {
		height: 2.97rem;
		background-position: 0% 0%;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		background-image: url(http://lak110.gitee.io/gdapp/src/images/wave.gif);
		mix-blend-mode: screen;
		vertical-align: middle;
	}


</style>
